package com.qzsoft.zhjd.asphalt.modules.asphaltmatch.controller;

import com.qzsoft.jeemis.common.validator.ValidatorUtils;
import com.qzsoft.zhjd.asphalt.modules.asphaltmatch.entity.AsphaltMatchColdEntity;
import com.qzsoft.zhjd.asphalt.modules.asphaltmatch.service.AsphaltMatchColdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.qzsoft.jeemis.common.utils.Result;
import com.qzsoft.zhjd.common.utils.ResultUtils;

/**
 * @ClassName AsphaltMatchColdController
 * @Description 沥青混合料冷料配比控制器
 * @author linhuawei
 * @since 2021-12-06
 */
@RestController
@RequestMapping("/api/asphaltMatchCold")
public class AsphaltMatchColdController {

    @Autowired
    private AsphaltMatchColdService asphaltMatchColdService;

    /**
     * @Title: find
     * @Description: 获取生产配比信息
     * @param id 生产配比主键
     * @return 生产配比信息
     */
    @GetMapping("/find/{id}")
    public Result<AsphaltMatchColdEntity> find(@PathVariable("id") String id) {
        AsphaltMatchColdEntity entity = asphaltMatchColdService.getById(id);
        return ResultUtils.ok(entity);
    }

    /**
     * @Title save
     * @Description 添加配比冷料配比
     * @param entity 配比信息
     * @return 添加结果
     */
    @PostMapping("/save")
    public Result<String> save(@RequestBody AsphaltMatchColdEntity entity) {
        ValidatorUtils.validateEntity(entity);
        asphaltMatchColdService.save(entity);
        return ResultUtils.ok();
    }

}
